package pl.edu.pw.ee.buildcity.logs;

import org.apache.log4j.Logger;

import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Mateusz
 * @since 2010-04-05
 */
public class LogsManager<T extends DefaultLogsHandler> {

	private static final Logger log = Logger.getLogger(LogsManager.class);

	private Map<String, T> loggers = new ConcurrentHashMap<String, T>();

	public void registerLogHandler(File workingCopy, T customLogHandler) {
		final String key = workingCopy.getAbsolutePath();
		log.debug("Registering log handler at key " + key);
		loggers.put(workingCopy.getAbsolutePath(), customLogHandler);
	}

	public T getLogHandler(String workingCopy) {
		log.debug("Searching for log handler with key: " + workingCopy);
		return loggers.get(workingCopy);
	}
}
